import 'package:flutter/material.dart';

class QualityItem extends StatelessWidget {
  final Map<String, dynamic> quality;
  const QualityItem({super.key, required this.quality});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16.0),
      margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(
            quality['temp'] > 950
                ? 'assets/images/centre/hot_8.png'
                : quality['temp'] > 900
                    ? 'assets/images/centre/hot_7.png'
                    : quality['temp'] > 850
                        ? 'assets/images/centre/hot_6.png'
                        : quality['temp'] > 800
                            ? 'assets/images/centre/hot_5.png'
                            : quality['temp'] > 750
                                ? 'assets/images/centre/hot_4.png'
                                : quality['temp'] > 700
                                    ? 'assets/images/centre/hot_3.png'
                                    : quality['temp'] > 650
                                        ? 'assets/images/centre/hot_2.png'
                                        : quality['temp'] > 600
                                            ? 'assets/images/centre/hot_1.png'
                                            : 'assets/images/centre/hot_1.png',
          ),
          fit: BoxFit.fill,
        ),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              Container(
                width: MediaQuery.of(context).size.width * 0.29,
                child: Text(
                  quality['pdiId'].toString(),
                  style: TextStyle(
                      fontSize: 15,
                      fontWeight: FontWeight.bold,
                      color: quality['temp'] > 950
                          ? Color(0xFF4E5969)
                          : Color.fromARGB(255, 231, 233, 235)),
                ),
              ),
              SizedBox(width: 5),
              Container(
                width: MediaQuery.of(context).size.width * 0.2,
                child: Text(
                  quality['diffTime'].toString(),
                  style: TextStyle(
                      fontSize: 15,
                      color: quality['temp'] > 950
                          ? Color(0xFF4E5969)
                          : Color.fromARGB(255, 231, 233, 235)),
                ),
              ),
              SizedBox(width: 5),
              Text(
                quality['point'].toString(),
                style: TextStyle(
                    fontSize: 15,
                    color: quality['temp'] > 950
                        ? Color(0xFFFF0000)
                        : Color(0xFFFFC300)),
              ),
            ],
          ),
          Align(
            alignment: Alignment.center,
            child: Text(
              quality['temp'].toString() + '℃',
              style: TextStyle(
                  fontSize: 15,
                  color: quality['temp'] > 950
                      ? Color(0xFFFF0000)
                      : Color(0xFFFFC300)),
            ),
          ),
        ],
      ),
    );
  }
}
